@extends('backend::common.common_right')
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <div class=" row m-b-sm m-t-sm">
                            <div class="col-md-6">
                                <form method="get" action="{{url('backend/model',['type'=>$type])}}">
                                <span class="checkbox col-md-2 m-r-xs" style="margin: 0px;padding: 0px">
                                    <select class="form-control catsshow" id="seach">
                                        <option value="title">模型名称</option>
                                        <option value="id">模型ID</option>
                                        <option value="name">用户名</option>
                                        <option value="mobile">手机号</option>
                                    </select>
                               </span>
                                    <div class="input-group">
                                        <input type="text" id="seachname" placeholder="搜索内容" name="title"
                                               class="form-control">
                                        <span class="input-group-btn">
                                     <button type="submit" class="btn  btn-primary"> 搜索</button>
                                     </span>
                                    </div>
                                </form>
                                <div  class="btn-group">
                                    <a class="btn btn-primary" href="{{url('backend/model',['type'=>$type])}}" aria-pressed="false">全部</a>
                                    <a class="btn btn-primary active" href="{{url('backend/model',['type'=>$type])}}?status=0" aria-pressed="true">待审核</a>
                                    <a class="btn btn-primary active" href="{{url('backend/model',['type'=>$type])}}?status=1" aria-pressed="true">已通过</a>
                                    <a class="btn btn-primary active" href="{{url('backend/model',['type'=>$type])}}?status=2" aria-pressed="true">未通过</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <table class="table table-striped table-bordered table-hover " id="editable">
                            <thead>
                            <tr>
                                <th>模型编号</th>
                                <th>模型名称</th>
                                <th>模型封面</th>
                                <th>所需交易币</th>
                                <th>作者</th>
                                <th>手机号</th>
                                <th>审核状态</th>
                                <th>VIP免费</th>
                                <th>上传时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($models as $da)
                                <tr class="gradeX">
                                    <td><a href="{{url($redirecturl)}}?modeId={{$da->id}}" target="__blank">{{$da->id}}</a></td>
                                    <td>{{$da->title}}</td>
                                    <td><img width="350" src="{{asset('/imagecache/model/'.$da->image)}}"></td>
                                    <td class="center">{{$da->coins}}</td>
                                    <td><a href="{{url('backend/userinfo',['id'=>$da->user_id])}}"
                                           class="text-navy">{{$da->user->name}}</a></td>
                                    <td class="center">{{$da->user->mobile}}</td>
                                    <td class="center">
                                        @if($da->status == 0)
                                            <button class="btn btn-xs btn-warning">待审核</button>
                                        @elseif($da->status == 1)
                                            <button class="btn btn-xs btn-primary">已通过</button>
                                        @else
                                            <button class="btn btn-xs btn-danger">未通过</button>
                                        @endif
                                    </td>
                                    <td class="center">
                                        @if($da->is_vip == 0)
                                            <button class="btn btn-xs btn-warning">否</button>
                                        @else
                                            <button class="btn btn-xs btn-primary">是</button>
                                        @endif
                                    </td>
                                    <td>{{$da->created_at}}</td>
                                    <td class="center">
                                        <a href="{{url('backend/modelcreate',['id'=>$da->id,'type'=>$type])}}"><i
                                                    class="fa fa-pencil"></i>编辑</a>&emsp;
                                        <a href="javascript:;" onclick="del({{$da->id}},{{$type}})"><i class="fa fa-trash"></i>删除</a>
                                        <a href="{{url('backend/modeldown',['id'=>$da->id])}}" ><i class="fa fa-cloud-download"></i>下载</a>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        {{$models->appends([
                                            'status' => !empty($status)?$status:'',
                                            'id' => !empty($id)?$id:'',
                                            'title' => !empty($title)?$title:'',
                                            'name' => !empty($name)?$name:'',
                                            'mobile' => !empty($mobile)?$mobile:'',
                                            ])->links()}}
                    </div>
                </div>
            </div>
        </div>
        <script>
            $('#seach').change(function () {
                var seachname = $(this).children('option:selected').val()
                $("#seachname").attr('name', seachname);
            })
            var del = function (id,type) {
                layer.confirm('确定删除么(不可恢复)？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    window.location.href = "{{url('backend/modeldel')}}/" +type+'/'+ id;
                }, function () {

                });
            }
        </script>

@endsection

